import 'package:interview/app/start_shared_preference_helper.dart';
import 'package:interview/config/device.dart';
import 'package:interview/config/network.dart';

class AppConfig {
  final String appName;
  final String version;
  final String buildNumber;
  final String environment;
  final String initialRoute;
  // final String apiBaseUrl;
  // final String webSocketUrl;
  // final bool isDebugMode;

  const AppConfig({
    required this.appName,
    required this.version,
    required this.buildNumber,
    required this.environment,
    required this.initialRoute,
    // required this.apiBaseUrl,
    // required this.webSocketUrl,
    // required this.isDebugMode,
  });
}


// 定义 AppStartRepository 抽象类
abstract class AppStartRepository<T> {
  Future<T> load();
}
class AppConfigRepository implements AppStartRepository<AppConfig> {
  const AppConfigRepository();
  @override
  Future<AppConfig> load() async {
    // 获取第几次进入app
    final bool isFirstLaunch  = await StartSharedPreferenceHelper.isAppInitialized();
    if(!isFirstLaunch ){
      await StartSharedPreferenceHelper.markAppInitialized();
    }

    await Device().initDeviceInfo();// 初始化设备信息
    // Network().listen();

    return AppConfig(
      appName: "面试通",
      version: "1.0.0",
      buildNumber: "100",
      environment: "debug",
      initialRoute: isFirstLaunch ? '/home' : '/start',
      // apiBaseUrl: "https://api.example.com",
      // webSocketUrl: "wss://ws.example.com",
      // initialRoute: "/home",
      // isDebugMode: false,
    );
  }
}
